package org.example.project.controller;

import org.example.project.service.impl.FileServiceImpl;
import org.example.project.util.FileUploadResponse;
import org.example.project.util.ResponseCode;
import org.example.project.util.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;

/**
 * @Author 岩
 * @Package org.example.project.controller
 * @Project MyApp
 * @Name FileUploadController
 * @Date 2024-05-02 17:32
 * @Filename FileUploadController
 */

@RestController
@RequestMapping("/file")
public class FileUploadController {
    @Resource
    private FileServiceImpl fileService;

    @PostMapping("/upload")
    public ResponseData upload(@RequestParam("file") MultipartFile file) {
        return new ResponseData(ResponseCode.success, fileService.upload(file));
    }
}
